home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 1999 #2
/
Amiga Plus CD - 1999 - No. 2.iso
/
System-Boost
/
Workbench
/
Archive
/
PPCxDMS
/
src
/
u_quick.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-06-18
|
995b
|
57 lines
/*
* xDMS v1.1 - Portable DMS archive unpacker - Public Domain
* Written by Andre R. de la Rocha <adlroc@usa.net>
*
*
*/
#include <string.h>
#include "cdata.h"
#include "u_quick.h"
#include "getbits.h"
#define QBITMASK 0xff
static USHORT quick_text_loc;
void Init_QUICK(void){
quick_text_loc = 251;
memset(text,0,252);
}
USHORT Unpack_QUICK(UCHAR *in, UCHAR *out, UCHAR flags, USHORT origsize){
USHORT i, j;
UCHAR *outend;
initbitbuf(in);
outend = out+origsize;
while (out < outend) {
if (GETBITS(1)!=0) {
DROPBITS(1);
*out++ = text[quick_text_loc++ & QBITMASK] = (UCHAR)GETBITS(8); DROPBITS(8);
} else {
DROPBITS(1);
j = (USHORT) (GETBITS(2)+2); DROPBITS(2);
i = (USHORT) (quick_text_loc - GETBITS(8) - 1); DROPBITS(8);
while(j--) {
*out++ = text[quick_text_loc++ & QBITMASK] = text[i++ & QBITMASK];
}
}
}
quick_text_loc = (USHORT)((quick_text_loc+5) & QBITMASK);
if (!(flags & 1)) Init_QUICK();
return 0;
}